<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let chengji = (a, b) => {
            let res = 1;
            for (let i = a; i <= b; i++) {
                res *= i;
            }
            return res //获得 a*a+1*a+2----*b
        }

        let jiecheng = (a, b, cb) => {
            let add = 0;
            for (let i = a; i <= b; i++) {
                if (cb) {
                    add += cb(a, i)
                } else {
                    add += i //求和
                }
            }
            return add
        }

        // console.log(jiecheng(1, 3, chengji))

    </script>
</body>

</html>